#ifndef ENGINE_CONSTANTBUFFER_H
#define ENGINE_CONSTANTBUFFER_H

enum CONSTBUFFER_TYPE
{
	CB_VS_PerBatch = 0,
	CB_MAX
};

enum CONSTBUFFER_COMMIT_TYPE
{
	CB_PerBatch = 0
};

class ConstantValue
{
public:
	ConstantValue();
	~ConstantValue();

	void SetValue(void* pInput);

	unsigned int	m_NameHashKey;
	char*			m_pValueName;
	unsigned int	m_SizeByte;
	unsigned int	m_OffsetByte;
	ConstantBuffer*	m_pConstantBuffer;	
};

class ConstantBuffer
{
public:
	ConstantBuffer();
	~ConstantBuffer();

	ConstantValue* GetConstantValue(char* pValueName);

	void CommitCB();

	CONSTBUFFER_TYPE	m_CBType;
	char*				m_pBufferName;
	unsigned int		m_BufferSlot;
	unsigned int		m_pBufferSize;
	unsigned char*		m_pBackBuffer;
	bool				m_bDirty;
	ID3D11Buffer*		m_pD3D11Buffer;

	map<unsigned int, ConstantValue*> m_mapConstValues;
};

class ConstantBufferManager
{
public:
	ConstantBufferManager();
	~ConstantBufferManager();

	ConstantBuffer* GetConstantBuffer(CONSTBUFFER_TYPE CBType);
	void CommitCB(CONSTBUFFER_COMMIT_TYPE CommitType);

	void CreateConstantBuffer();

private:
	map<CONSTBUFFER_TYPE, ConstantBuffer*> m_vecConstantBuffers;
};

extern ConstantBufferManager GConstantBufferManager;

#endif